﻿using Microsoft.Data.Sqlite;
using CRL;
using CRL.DBAccess;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CRL.Sqlite
{
    public static class Extension
    {
        public static IDbConfigRegister UseSqlite(this IDbConfigRegister iBuilder)
        {
            var builder = iBuilder as DBConfigRegister;
            builder.RegisterDBType(DBType.SQLITE, (dBAccessBuild) =>
            {
                return new SqliteHelper(dBAccessBuild);
            }, (context) =>
            {
                return new SqliteDBAdapter(context);
            });
            builder.RegisterConnectionTypeMapping(nameof(SqliteConnection), DBType.SQLITE);
            return builder;
        }
    }
}
